//
// Created by lm379 on 25-3-12.
//
#include<iostream>
using namespace std;

typedef struct LNode {
    int data;
    LNode *next;
} LNode;

bool isEqual(LNode *L1,LNode *L2) {
    LNode *p=L1->next,*q=L2->next;
    while (p != nullptr && q != nullptr) {
        if (p->data != q->data) {
            return false;
        }
        p = p -> next;
        q = q -> next;
    }
    if (p != nullptr||q != nullptr) return false;
    return true;
}

void CreateList(LNode *&head, const int arr[], const int length) {
    LNode *p = nullptr;
    head = (LNode*)malloc(sizeof(LNode));
    head -> next = NULL;
    p = head;
    for (int i = 0;i<length;i++) {
        LNode *q = (LNode*)malloc(sizeof(LNode));
        q -> data = arr[i];
        q -> next = nullptr;
        p -> next = q;
        p = q;
    }
}

int main() {
    int arr1[] = {1,2,4,5,9};
    int arr2[] = {1,2,4,5,6,9};
    LNode *head1,*head2;
    CreateList(head1,arr1,size(arr1));
    CreateList(head2,arr2,size(arr2));
    if (isEqual(head1,head2)) {
        cout << "true";
    }else {
        cout << "false";
    }
    cout << endl;
    return 0;
}
